package com.silong.swing;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import javax.swing.*;
import java.awt.*;

@SpringBootApplication
public class SwingApplication {

    public static void main(String[] args) {

        //SpringApplication.run(SwingApplication.class, args);
        JFrame jFrame = new JFrame();
        jFrame.setSize(600, 600); //窗体大小
        //jFrame.setLocation(100,200); //窗体显示位置
        jFrame.setLocationRelativeTo(null); //让窗体显示到正中间
        jFrame.setTitle("Swing第一个窗口"); //显示窗体标题
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗体时退出程序
        //查找主窗体位置
        Container contentPane = jFrame.getContentPane();
        contentPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); //从左到右排序
        //创建一个流式布局，以及参数配置
        //部件对齐的方式：FlowLayout.Leading根据第一个部件走，FlowLayout.Tailing根据最后一个部件走
        //部件之间的间距：50为横向边距，30中垂直间隔
        FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 50, 30); //布局左对齐

        contentPane.setLayout(flowLayout);

        JButton cmdOk = new JButton();
        JButton cmdClose = new JButton("关闭(&C)");
        cmdOk.setText("我是按钮");
        contentPane.add(cmdOk);
        contentPane.add(cmdClose);

        jFrame.setVisible(true); //显示窗体

    }

}
